"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const api_evaluation_index = require("../../../api/evaluation/index.js");
const api_police_index = require("../../../api/police/index.js");
const api_complaint_index = require("../../../api/complaint/index.js");
const utils_tools = require("../../../utils/tools.js");
const stores_userInfo = require("../../../stores/userInfo.js");
if (!Array) {
  const _easycom_userOfTopLeft2 = common_vendor.resolveComponent("userOfTopLeft");
  const _easycom_up_swiper2 = common_vendor.resolveComponent("up-swiper");
  const _easycom_up_grid_item2 = common_vendor.resolveComponent("up-grid-item");
  const _easycom_up_grid2 = common_vendor.resolveComponent("up-grid");
  const _easycom_qiun_data_charts2 = common_vendor.resolveComponent("qiun-data-charts");
  const _easycom_up_gap2 = common_vendor.resolveComponent("up-gap");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_userOfTopLeft2 + _easycom_up_swiper2 + _easycom_up_grid_item2 + _easycom_up_grid2 + _easycom_qiun_data_charts2 + _easycom_up_gap2 + _easycom_up_toast2)();
}
const _easycom_userOfTopLeft = () => "../../../components/userOfTopLeft/userOfTopLeft.js";
const _easycom_up_swiper = () => "../../../node-modules/uview-plus/components/u-swiper/u-swiper.js";
const _easycom_up_grid_item = () => "../../../node-modules/uview-plus/components/u-grid-item/u-grid-item.js";
const _easycom_up_grid = () => "../../../node-modules/uview-plus/components/u-grid/u-grid.js";
const _easycom_qiun_data_charts = () => "../../../uni_modules/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.js";
const _easycom_up_gap = () => "../../../node-modules/uview-plus/components/u-gap/u-gap.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_userOfTopLeft + _easycom_up_swiper + _easycom_up_grid_item + _easycom_up_grid + moduleOuterBox + _easycom_qiun_data_charts + _easycom_up_gap + _easycom_up_toast)();
}
const moduleOuterBox = () => "../../../components/moduleOuterBox/moduleOuterBox.js";
const _sfc_defineComponent = common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    const userInfoStore = stores_userInfo.useUserInfoStore();
    const uToastRef = common_vendor.ref(null);
    const current = common_vendor.ref(0);
    const swipers = common_vendor.reactive([
      "https://mscy.cqlandun.com:8088/static/police-banner1.png",
      "https://mscy.cqlandun.com:8088/static/police-banner2.png",
      "https://mscy.cqlandun.com:8088/static/police-banner3.png"
    ]);
    const data = common_vendor.reactive({
      policeStatusCount: [
        {
          num: 0,
          title: "今日在岗"
        },
        {
          num: 0,
          title: "今日不在岗"
        }
      ],
      evaluationType: 0,
      complaintType: 0,
      params: {
        policeLeaderId: userInfoStore.userInfo.userId,
        communityId: null
      },
      complaintMonth: {
        total: 0,
        chartData: {}
      },
      complaintYear: {
        total: 0,
        chartData: {}
      },
      otherDataStat: [
        {
          num: 0,
          title: "办事咨询",
          color: "#F2AD32",
          bgColor0: "#FEF9EC",
          bgColor1: "#FFFCF7"
        },
        {
          num: 0,
          title: "注册用户量",
          color: "#F4806C",
          bgColor0: "#F9FEFD",
          bgColor1: "#F3FFFB"
        },
        {
          num: 0,
          title: "办理点击量",
          color: "#459BFD",
          bgColor0: "#F3F9FE",
          bgColor1: "#EEF6FC"
        }
      ]
    });
    const {
      policeStatusCount,
      evaluationType,
      complaintType,
      params,
      complaintMonth,
      complaintYear,
      otherDataStat
    } = common_vendor.toRefs(data);
    const evaluationChartMonth = common_vendor.reactive({
      chartData: {},
      opts: {
        animation: false,
        // 关闭动画
        update: true,
        // 关键：是否开启连续更新数据的方法,开启之后就不会抖动了
        duration: 0,
        // 关闭动画过度
        rotate: false,
        rotateLock: false,
        color: ["#39FB00", "#4AABFF", "#F55300"],
        padding: [10, 10, 10, 10],
        dataLabel: true,
        enableScroll: false,
        legend: {
          show: false
        },
        title: {},
        subtitle: {
          name: ""
        },
        extra: {
          ring: {
            ringWidth: 20,
            //圆环的宽度
            centerColor: "#ffffff",
            //中间填充圆形的颜色
            activeOpacity: 0.5,
            //启用Tooltip点击时，突出部分的透明度
            activeRadius: 8,
            //启用Tooltip点击时，突出部分的宽度
            offsetAngle: 0,
            //起始角度偏移度数，顺时针方向，
            labelWidth: 15,
            //数据标签到饼图外圆连线的长度
            border: false
            //是否绘制各类别中间的分割线
          }
        }
      }
    });
    const evaluationChartYear = common_vendor.reactive({
      chartData: {},
      opts: {
        animation: false,
        // 关闭动画
        update: true,
        // 关键：是否开启连续更新数据的方法,开启之后就不会抖动了
        duration: 0,
        // 关闭动画过度
        rotate: false,
        rotateLock: false,
        color: ["#39FB00", "#4AABFF", "#F55300"],
        padding: [10, 10, 10, 10],
        dataLabel: true,
        enableScroll: false,
        legend: {
          show: false
        },
        title: {},
        subtitle: {
          name: ""
        },
        extra: {
          ring: {
            ringWidth: 20,
            //圆环的宽度
            centerColor: "#ffffff",
            //中间填充圆形的颜色
            activeOpacity: 0.5,
            //启用Tooltip点击时，突出部分的透明度
            activeRadius: 8,
            //启用Tooltip点击时，突出部分的宽度
            offsetAngle: 0,
            //起始角度偏移度数，顺时针方向，
            labelWidth: 15,
            //数据标签到饼图外圆连线的长度
            border: false
            //是否绘制各类别中间的分割线
          }
        }
      }
    });
    const complaintChartOpts = common_vendor.ref({
      animation: false,
      // 关闭动画
      update: true,
      // 关键：是否开启连续更新数据的方法,开启之后就不会抖动了
      duration: 0,
      // 关闭动画过度
      padding: [10, 5, 5, 0],
      enableScroll: false,
      //true,
      legend: { show: false },
      dataLabel: false,
      // 不显示数据标签
      xAxis: {
        rotateLabel: true,
        // 启用旋转功能减少横向空间占
        rotateAngle: 45,
        // 文字旋转的角度，取值范围(-90至90)
        // scrollShow: true,
        // itemCount: 8,
        interval: 0,
        boundaryGap: "justify",
        // 让柱状图两端不留空白
        disableGrid: true,
        //不绘制纵向网格
        fontColor: "#000000",
        //字体颜色
        fontSize: 10,
        //字体大小
        axisLineColor: "#707070",
        //坐标轴轴线颜色
        marginTop: "5",
        //X轴文字距离轴线的距离
        // labelCount: 6, //数据点文字单屏幕限制显示的数量
        formatter: function(value, index, opts) {
          return value;
        }
      },
      yAxis: {
        disableGrid: true,
        //不绘制横向向网格
        data: [
          {
            min: 0,
            calibration: true,
            //刻度线是否显示
            fontColor: "#8A8A8A",
            //字体颜色
            fontSize: 12,
            //字体大小
            axisLineColor: "#707070"
            //坐标轴轴线颜色
          }
        ]
      },
      extra: {
        column: {
          type: "group",
          width: 10,
          linearType: "custom",
          //渐变类型
          customColor: ["#88C5EC", "#4299FE"],
          activeBgColor: "#000000",
          //当前点击柱状图的背景颜色
          activeBgOpacity: 0.08
          //当前点击柱状图的背景颜色透明度
        }
      }
    });
    const getStatusStat = () => {
      api_police_index.policeStatusStat().then((res) => {
        const { data: data2 } = res;
        policeStatusCount.value[0].num = data2.dutyCount;
        policeStatusCount.value[1].num = data2.noDutyCount;
        otherDataStat.value[0].num = data2.consultCount;
        otherDataStat.value[1].num = data2.registerUserCount;
        otherDataStat.value[2].num = data2.handleClickCount;
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const updatecomplaintStat = (mode) => {
      complaintType.value = mode;
    };
    const getComplaintStat = (type) => {
      let param = {};
      if (type === 0) {
        param = {
          ...params.value,
          ...{
            type,
            yearMonth: common_vendor.dayjs(/* @__PURE__ */ new Date()).format("YYYY-MM")
          }
        };
      } else {
        param = {
          ...params.value,
          ...{
            type,
            yearMonth: common_vendor.dayjs(/* @__PURE__ */ new Date()).format("YYYY")
          }
        };
      }
      api_complaint_index.complaintStat(param).then((res) => {
        const { data: data2 } = res;
        data2.cltCmyChartVos = data2.cltCmyChartVos ?? [];
        let xdata = [];
        let ydata = [];
        if (data2.cltCmyChartVos.length) {
          data2.cltCmyChartVos.forEach((item) => {
            xdata.push(item.communityName);
            ydata.push(+item.communityCount);
            if (type === 0) {
              complaintMonth.value.total += +item.communityCount;
            } else {
              complaintYear.value.total += +item.communityCount;
            }
          });
        }
        let seriesData = {
          categories: xdata,
          series: [
            {
              name: "投诉次数",
              data: ydata
            }
          ]
        };
        if (type === 0) {
          complaintMonth.value.chartData = JSON.parse(JSON.stringify(seriesData));
        } else {
          complaintYear.value.chartData = JSON.parse(JSON.stringify(seriesData));
        }
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const updateEvaluationStat = (mode) => {
      evaluationType.value = mode;
    };
    const getEvaluationStat = (type) => {
      let seriesData = {
        series: [
          {
            data: [
              {
                name: "满意",
                value: 0,
                labelText: `满意：0%`
              },
              {
                name: "一般",
                value: 0,
                labelText: `一般：0%`
              },
              {
                name: "不满意",
                value: 0,
                labelText: `不满意：0%`
              }
            ]
          }
        ]
      };
      let title = {
        name: 0,
        fontSize: 25,
        color: "#000000"
      };
      let param = {};
      if (type === 0) {
        param = {
          ...params.value,
          ...{
            type,
            yearMonth: common_vendor.dayjs(/* @__PURE__ */ new Date()).format("YYYY-MM")
          }
        };
      } else {
        param = {
          ...params.value,
          ...{
            type,
            yearMonth: common_vendor.dayjs(/* @__PURE__ */ new Date()).format("YYYY")
          }
        };
      }
      api_evaluation_index.evaluationStat(param).then((res) => {
        const { data: data2 } = res;
        if (data2.sumCount > 0) {
          seriesData.series[0].data[0].value = +data2.satisfiedCount;
          seriesData.series[0].data[0].labelText = `满意：${utils_tools.toFixedWithoutTrailingZeros(
            data2.satisfiedCount / +data2.sumCount * 100
          )}%`;
          seriesData.series[0].data[1].value = +data2.generalCount;
          seriesData.series[0].data[1].labelText = `一般：${utils_tools.toFixedWithoutTrailingZeros(
            data2.generalCount / +data2.sumCount * 100
          )}%`;
          seriesData.series[0].data[2].value = +data2.dissatisfiedCount;
          seriesData.series[0].data[2].labelText = `不满意：${utils_tools.toFixedWithoutTrailingZeros(
            data2.dissatisfiedCount / +data2.sumCount * 100
          )}%`;
          title.name = +data2.sumCount;
        }
        if (type === 0) {
          evaluationChartMonth.chartData = JSON.parse(JSON.stringify(seriesData));
          evaluationChartMonth.opts.title = JSON.parse(JSON.stringify(title));
        } else {
          evaluationChartYear.chartData = JSON.parse(JSON.stringify(seriesData));
          evaluationChartYear.opts.title = JSON.parse(JSON.stringify(title));
        }
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const initData = () => {
      getStatusStat();
      getEvaluationStat(0);
      getEvaluationStat(1);
      getComplaintStat(0);
      getComplaintStat(1);
    };
    common_vendor.onMounted(() => {
      initData();
    });
    common_vendor.onShow(() => {
      common_vendor.index.hideHomeButton();
    });
    common_vendor.onShareAppMessage((res) => {
      return {
        title: "码上朝阳",
        path: "/pages/crowd/home/index",
        imageUrl: "/static/logo.png",
        content: "我的码上朝阳小程序",
        mpId: "wxbaec7c3e7b23e9c4",
        type: 0
      };
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.unref(userInfoStore).token
      }, common_vendor.unref(userInfoStore).token ? {
        b: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/leader/mine/index")),
        c: common_vendor.p({
          userAvatar: common_vendor.unref(userInfoStore).userInfo.avatar,
          userName: common_vendor.unref(userInfoStore).userInfo.userName
        })
      } : {
        d: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/pages/register/register")),
        e: common_vendor.p({
          userAvatar: "",
          userName: "未登录",
          showMoreIcon: false
        })
      }, {
        f: common_vendor.f(common_vendor.unref(swipers), (item, index, i0) => {
          return {
            a: index,
            b: common_vendor.n(index === common_vendor.unref(current) && "indicator__dot--active")
          };
        }),
        g: common_vendor.o((e) => current.value = e.current),
        h: common_vendor.p({
          list: common_vendor.unref(swipers),
          circular: true,
          height: "360rpx",
          radius: "16rpx"
        }),
        i: common_vendor.f(common_vendor.unref(policeStatusCount), (item, index, i0) => {
          return {
            a: common_vendor.t(item.num),
            b: common_vendor.t(item.title),
            c: index,
            d: "361e734c-5-" + i0 + ",361e734c-4"
          };
        }),
        j: common_vendor.p({
          border: false,
          align: "center",
          col: "2"
        }),
        k: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/leader/policeStatus/index")),
        l: common_vendor.p({
          moduleTitle: "社区民警状态",
          moduleIcon: common_vendor.unref(common_assets.sqmjztIcon)
        }),
        m: common_vendor.p({
          type: "ring",
          opts: common_vendor.unref(evaluationType) === 0 ? common_vendor.unref(evaluationChartMonth).opts : common_vendor.unref(evaluationChartYear).opts,
          chartData: common_vendor.unref(evaluationType) === 0 ? common_vendor.unref(evaluationChartMonth).chartData : common_vendor.unref(evaluationChartYear).chartData
        }),
        n: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/leader/serviceEvaluation/index")),
        o: common_vendor.o(updateEvaluationStat),
        p: common_vendor.p({
          moduleTitle: "服务评价统计",
          moduleIcon: common_vendor.unref(common_assets.fwpjtjIcon),
          showQuery: true,
          modeType: common_vendor.unref(evaluationType)
        }),
        q: common_vendor.p({
          type: "column",
          opts: common_vendor.unref(complaintChartOpts),
          tooltipFormat: "normalTooltip",
          chartData: common_vendor.unref(complaintType) === 0 ? common_vendor.unref(complaintMonth).chartData : common_vendor.unref(complaintYear).chartData
        }),
        r: common_vendor.o(($event) => common_vendor.unref(utils_tools.onPageJump)("/subPages/leader/reportComplaint/index")),
        s: common_vendor.o(updatecomplaintStat),
        t: common_vendor.p({
          moduleTitle: "举报投诉统计",
          moduleIcon: common_vendor.unref(common_assets.jbtstjIcon),
          showQuery: true,
          modeType: common_vendor.unref(complaintType),
          showTotal: true,
          totalNum: common_vendor.unref(complaintType) === 0 ? common_vendor.unref(complaintMonth).total : common_vendor.unref(complaintYear).total
        }),
        v: common_vendor.f(common_vendor.unref(otherDataStat), (item, index, i0) => {
          return {
            a: common_vendor.t(item.num),
            b: common_vendor.s(`color:${item.color};`),
            c: common_vendor.t(item.title),
            d: common_vendor.s(`background: linear-gradient(180deg, ${item.bgColor0} 0%, ${item.bgColor1} 100%);`),
            e: index,
            f: "361e734c-12-" + i0 + ",361e734c-11"
          };
        }),
        w: common_vendor.p({
          border: false,
          align: "center",
          gap: "18rpx"
        }),
        x: common_vendor.p({
          moduleTitle: "其他数据统计",
          moduleIcon: common_vendor.unref(common_assets.qtsjtjIcon)
        }),
        y: common_vendor.p({
          height: "16"
        }),
        z: common_vendor.sr(uToastRef, "361e734c-14", {
          "k": "uToastRef"
        })
      });
    };
  }
});
_sfc_defineComponent.__runtimeHooks = 2;
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_defineComponent, [["__scopeId", "data-v-361e734c"]]);
wx.createPage(MiniProgramPage);
